/**
 * 
 */

$(document).ready(function(e)
{
	$("#navBar a").live("click",function(e)
	{
		e.preventDefault();


		// I change the class for active so I can change the style even with
		// an ajax call.
		$('#navBar a').each(function()
		{
			$(this).removeClass('active');
		});
		
		$(this).addClass('active');
		
		// I delete the backslashes so I can build an url
		var section = $(this).attr("href");
		
		
		section = section.replace('/','');
		
		
		section = section.replace('/','');
		
		// I add that page to tracking for google analytics.
		var section_analytics = "/"+section; // '/about'
		
		// If _gaq is not undefined (localhost and production tests)
		if(typeof _gaq != 'undefined') 
			_gaq.push(['_trackPageview', section_analytics]);
		
		section += ".php";
		

		
		
		$('article#text').fadeOut(300, function()
		{
			// After we have fadeOut the text, we call to ajax to bring
			// the new text.

			$.get(section, function(data)
			{ 
				$("article#text").html(data);
				$("article#text").fadeIn(600);
			});
		});
		
	});
	
	

	//-------------------------------------------------------------------------
});





